package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.service.UserService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

/**
 * 目标：使用注解把UserServiceImpl的对象放入到spring容器
 *
 * @Component: 组件类，放在类中，spring容器会创建对象。创建的对象的名称是类的首字母小写名称
 * @Scope作用：声明单例或者多例，默认就是单例
 */
//@Component("userService")
@Service("userService")
@Scope
public class UserServiceImpl implements UserService {

    public UserServiceImpl() {
        System.out.println("无参构造函数调用");
    }

    //UserServiceImpl中依赖UserDao
    private UserDao userDao;

    @Override
    public void save() {
        userDao.save();
        System.out.println("UserServiceImpl.save");
    }
}
